<?php
/* @var $this QuotationOrderHeaderController */
/* @var $model QuotationOrderHeader */

$this->breadcrumbs=array(
	'Quotation'=>array('index'),
	'Create',
);
Yii::app()->clientScript->registerScript('search', "
$('#attention').blur(function(){
	document.getElementById('employee_id').value='".Yii::app()->session['id']."';
	return true;
});
 function addItem(){
        $(this).dialog('close');
        var tempQuoNo=$('#tempQuoNo').val();
        var customer=$('#customerPick').val();
        
        var matches = customer.match(/\b(\w)/g);
        var tempCustomer = matches.join('');

        tempQuoNo=tempQuoNo.replace('?',tempCustomer.toUpperCase());
        $('#quotation_no').val(tempQuoNo);
        $('#customer_name').val(customer);
 }

");

$this->menu=array(
	array('label'=>'List QuotationOrderHeader', 'url'=>array('index')),
);
?>

<h1>Create Quotation Order</h1>

<?php $this->renderPartial('_form', array('model'=>$model,'quo_no'=>$quo_no)); ?>


<?php

	$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
        'id'=>'customer_dialog',
        'options'=>array(
            'title'=>'Select Customer',
            'autoOpen'=>true,
            'modal'=>true,
			'width'=>520,
            'buttons'=>array(
                'Submit'=>'js:addItem',
                'Cancel'=>'js:function(){ $(this).dialog("close");}',
            ),
        ),
    ));
	
    echo '<table width="300px">
            <tr>
                <td width="400px">';
                   $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
                        //'model'=>$model,
                        //'attribute'=>'name',
                        'id'=>'customerPick',
                        'name'=>'customer',
                        'source'=>$this->createUrl('quotationOrderHeader/suggestCountry'),
                        'htmlOptions'=>array(
                            //'size'=>'40',
                            'select'=>"js:function(event, ui) { 
                                $('#tempIdCust').val(); 
                            }"
                        ),
                    ));

    echo'            </td>
                <td width="100px">
                    <input type="hidden" id="tempQuoNo" value="'.$this->getQuoNo().'"/>
                </td>
                <td width="100px">';
                DialogBox::createDialogBox(
					 $this
					,"addCustomer"
					,"Type new customer:"
					,"quotationOrderHeader/customer"
					,"customerPick"
					,"sampleIconCssStyle"
					,475,510
				); 
    echo '      </td>
            </tr>
          </table>
        ';
    $this->endWidget('zii.widgets.jui.CJuiDialog');
	
?>
